import { HttpClient } from "@angular/common/http";
import { Injectable, ɵConsole } from "@angular/core";
import { Location } from "@angular/common";
import { catchError } from "rxjs/operators";
import { Observable } from "rxjs";
import { NzModalService, NzMessageService } from "ng-zorro-antd";
import { Subject } from "rxjs";
import { scene,orientation } from "../../model/camera.model";
declare var Cesium;
@Injectable()
export class cesiumCamera {
  public Viewer:any
  public constructor() {

  }

  /**
   * 创建摄像头
   * @param scene 
   * @returns 
   */
  public Camera(scene: scene) {
    let camera = new Cesium.Camera(scene);
    return camera;
  }

  /**
   * 初始化设置视野居中位置
   * @param Viewer 
   * @param destination 
   * @param orientation (long，精度，lat维度，distance，距离)
   */
  public setView(Viewer:any,destination:any,orientation:orientation){
    this.Viewer=Viewer
    this.Viewer.camera.setView({
      destination:Cesium.Cartesian3.fromDegrees(destination.long,destination.lat, destination.distance),
      orientation: orientation
    });
  }
  

  public addEventListener(Viewer:any, callback?: Function){
    this.Viewer.camera.changed.addEventListener((percentage) => {
      // console.log(this.Viewer.camera)
      // console.log(this.InitCesiumService.getCenterPosition());
      // console.log(this.Viewer.scene.camera.heading);
      // console.log(this.Viewer.scene.camera.pitch);
      // console.log(this.Viewer.scene.camera.roll);
      // console.log(this.Viewer.scene.camera.position);
      callback(percentage)
    });

    
  }

}
